<template>
	<div class="root">
		<textarea name="" id="" cols="30" rows="10" v-model="message" placeholder="给我们留言"></textarea>
		<button class="sub-button" @click="onSubmit">保存</button>
		<p>感谢给我们留言，我们会不断进步</p>
	</div>
</template>

<script>
	import { Notify } from 'vant';
	export default{
		data(){
			return{
				message:''
			}
		},
		methods:{
			onSubmit(){
				if(this.message.trim().length<10){
					Notify({ type: 'warning', message: "'建议'不能少于10个字符" });
					return false
				}
				let user_id = this.$route.query.user_id
				this.$axios.post('user/message',{user_id,message:this.message})
				.then(res=>{
					if (res.data.code==2000) {
						Notify({ type: 'success', message: '提交成功!感谢您的建议!' });
						this.$router.push('/mine')
					} else{
						Notify({ type: 'warning', message: res.data.msg });
					}
					console.log(res)
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.root{
		padding: 2rem;
		textarea{
			box-sizing: border-box;
			width: 85vw;
			height: 18rem;
			padding: 1rem;
			border: .1rem solid #ccc;
			line-height: 1.5rem;
		}
		.sub-button{
			width: 100%;
			height: 3.5rem;
			box-sizing: border-box;
			background: linear-gradient(to right, #1FCAD1, #0383C4);
			border: none;
			outline: none;
			margin-top: 4rem;
			margin-right: 10vw;
			border-radius: 3rem;
			color: #fff;
			font-size: 1.3rem;
		}
		p{
			text-align: center;
			margin-top: 1rem;
		}
	}
</style>
